package com.hh.userservice;

import feign.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
//@EnableFeignClients // 开启feign 的客户端功能 才可以帮助我们发起调用
@EnableFeignClients(basePackages = {"com.hh.userservice.feign"})
public class UserServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(UserServiceApplication.class, args);
        // @EnableFeignClients 拿到注解里的东西
        // basePackages如果没有写 他会扫描本类下面所有的包判断是否需要创建代理对象
        // @EnableFeignClients(basePackages = {"com.hh.userservice.feign"}) 注定包扫描 可以加快启动时间
//        ConfigurableApplicationContext run = SpringApplication.run(UserServiceApplication.class, args);
//        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
//        Object beanName = context.getBean("beanName");
//        Class<UserServiceApplication> userServiceApplicationClass = UserServiceApplication.class;
//        SpringBootApplication annotation = userServiceApplicationClass.getAnnotation(SpringBootApplication.class);
    }

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    /**
     * feign的日志
     * 打印日志的级别 feign
     * @return
     */
    @Bean
    public Logger.Level level() {
        return Logger.Level.FULL;
    }

}
